﻿using SmartMotion.Core;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using EventMgrLib;
using WeifenLuo.WinFormsUI.Docking;

namespace SmartMotion.AllPages.DockPanels
{
    public partial class FrmFLowChartEdit : DockContent
    {
        private EventMgr _em;
        private Flow _flow;
        public FrmFLowChartEdit()
        {
            InitializeComponent();
            Load += FrmFLowChartEdit_Load;
            GotFocus += FrmFLowChartEdit_GotFocus;
            LostFocus += FrmFLowChartEdit_LostFocus;
            FormClosed += FrmFLowChartEdit_FormClosed;
        }

        private void FrmFLowChartEdit_Load(object sender, EventArgs e)
        {
            _em=EventMgr.Ins;
            删除ToolStripMenuItem.Click += 删除ToolStripMenuItem_Click;
        }

        private void FrmFLowChartEdit_FormClosed(object sender, FormClosedEventArgs e)  
        {
           
        }

        private void FrmFLowChartEdit_LostFocus(object sender, EventArgs e)
        {
            if (_flow != null)
            {
                //_em.GetEvent<StatusLabelMsg>().Publish(_flow.Name+"LostFocus");
                canvas1.LostFocus();
            }
        }

        private void FrmFLowChartEdit_GotFocus(object sender, EventArgs e)
        {
            if (_flow != null)
            {
                //_em.GetEvent<StatusLabelMsg>().Publish(_flow.Name + "GetFocus");
                canvas1.GetFocus();
            }
        }


        private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            canvas1.Delete();
        }

        internal void LoadFlow(Flow flow)
        {
            _flow = flow;
            canvas1.Import(flow);
        }
    }
}
